import { useUserStore } from '@/stores/userStore.js'
import { FILE_PREFIX } from '@/config/myConfiguration.js'

function getCurrentDriverAvatarOrDefault() {
	return useUserStore().getCurrentDriver().profileImg && useUserStore().getCurrentDriver().profileImg.indexOf('/profile') !== -1
		? 
		`${FILE_PREFIX}${useUserStore().getCurrentDriver().profileImg}` 
		: 
		'/static/driver-avatar.png'
}

function getUserAvatarOrDefault(avatar) {
	return avatar
		? 
		`${FILE_PREFIX}${avatar}` 
		: 
		'/static/user-avatar.png'
}

function getImageUrlWithDomain(url) {
	if (url.indexOf(FILE_PREFIX) !== -1) {
		return url
	}
	return `${FILE_PREFIX}${url}`
}

export {
	getCurrentDriverAvatarOrDefault,
	getUserAvatarOrDefault,
	getImageUrlWithDomain
}